package com.zzxz.practicaltrainingsys.mapper;

import com.zzxz.practicaltrainingsys.entity.Log;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.tomcat.jni.OS;

import java.util.List;

import static eu.bitwalker.useragentutils.Browser.IE;

@Mapper
public interface LogMapper {
    @Insert("INSERT INTO log(userID, IP_Address, OS, IE, CreateDate, Remark) " +
            "VALUES(#{userID}, #{IpAddress}, #{OS}, #{IE}, #{createDate}, #{remark})")
    @Options(useGeneratedKeys = true, keyProperty = "logID")
    int insertLog(Log log);

    @Select("SELECT logID, userID,IP_Address AS IpAddress, OS, IE,CreateDate AS createDate,Remark AS remark " +
            "FROM `log`\n" +
            "        ORDER BY CreateDate DESC")
    List<Log> getLogList();
}
